<?php
class MediaObject extends CI_Model {

	//mo3ath
	function addMedia($name,$description,$type,$url,$xpoint,$ypoint,$webComponentName,$contexId){
		$new_media = array(
			'name' => $name,
			'description' => $description,
			'type' => $type,
			'url' => $url,
			'xPoint' => $xpoint,
			'yPoint' => $ypoint,
			'webComponentName' => $webComponentName,
			'Context_id' => $contexId
		);
		$insert = $this->db->insert('mediaobject', $new_media);
		
		return $this->db->insert_id();
	}
	//mo3ath
	function getMediaContext($contextId){
		
		$this->db->where('Context_id', $contextId);
		$query = $this->db->get('mediaobject');
		
		return $query->result();
	}
	function getMedia($id){
		
		$this->db->where('id', $id);
		$query = $this->db->get('mediaobject');
		
		return $query->result();
	}

	
	//Houssam
	function AddComponent($componentname)
	{
		// i'm assuming that the context id will be given from a field.
		if($componentname==null)
		{
			echo 'the component name is empty...Good Bye';
		}
		else 
		{
			$cid= $_POST['Context_ID'];
			$data= array (
							'webComponentName' => $componentname
						 );
			$this -> db -> where('Context_id', $cid);
			
			$update = $this->db-> update('mediaobject',$data);
			return $update;
		}
	}

}
